package net.omnivention.wulumuqi.html;

import org.jdom.Comment;
import org.jdom.Element;

public class Calendar extends HtmlElement {

	public Calendar(String name) {
		super("div");
		setNamespace(HtmlElementFactory.htmlns);

		Element input = HtmlElementFactory.createElement("input");
		input.setAttribute("id",name);
		input.setAttribute("name",name);
		input.setAttribute("type","text");
		addContent(input);
		
		// image
		A a = new A();
		a.setAttribute("id","trigger");
		Element image = HtmlElementFactory.createElement("image");
		image.setAttribute("src", "images/calendar.png");
		image.setAttribute("width", "16");
		image.setAttribute("height", "16");
		a.addContent(image);
		addContent(a);
		
		// script
		Element script = HtmlElementFactory.createElement("script");
		script.setAttribute("type","text/javascript");
		String js = "\n\tCalendar.setup({\n\t"+
		"inputField: \""+name+"\",\n\t"+
		"ifFormat: \"%Y-%m-%d %H:%M:%S\",\n\t"+
		"button: \"trigger\",\n\t"+
		"showsTime: true,\n\t"+	
		"step: 1\n\t});\n\t";
		Comment c = new Comment(js);
		script.addContent(c);
		addContent(script);

	}

	public Calendar() {
		this(null);
	}
}
